#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ls x<<1
#define rs x<<1|1
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define ll long long
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
const int N = 4e5+5;
int n;
ll a[N],b[N];
struct tree
{
    ll t[N<<2],tag[N<<2];int cnt[N<<2];bool tp;
    void pushtag(int x,ll v)
    {t[x] += v*cnt[x];tag[x] += v;}
    void pushdown(int x)
    {
        ll &v = tag[x];
        if(v)pushtag(ls,v),pushtag(rs,v),v = 0;
    }
    void update(int x)
    {t[x] = t[ls]+t[rs];cnt[x] = cnt[ls]+cnt[rs];}
    int modify(int x,int l,int r,int i,ll v)
    {
        if(l == r){int y = (cnt[x] ^= 1)?1:-1;return t[x] = ~y?v:0,y;}
        int mid = l+r>>1;pushdown(x);
        int ans = i <= mid?modify(lson,i,v):modify(rson,i,v);
        return update(x),ans;
    }
    void modify(int x,int l,int r,int L,int R,ll v)
    {
        if(L <= l&&r <= R)return pushtag(x,v);
        int mid = l+r>>1;pushdown(x);
        if(L <= mid)modify(lson,L,R,v);
        if(mid < R)modify(rson,L,R,v);
        t[x] = t[ls]+t[rs];
    }
    ll query(int x,int l,int r,int k,bool flag)
    {
        if(l == r)return t[x];
        int mid = l+r>>1;pushdown(x);
        if(!tp)if(k <= cnt[ls])return query(lson,k,flag);
        else return flag*t[ls]+query(rson,k-cnt[ls],flag);
        else if(k <= cnt[rs])return query(rson,k,flag);
        else return flag*t[rs]+query(lson,k-cnt[rs],flag);
    }
    int get(int x,int l,int r,int i)
    {
        if(l == r)return cnt[x];
        int mid = l+r>>1;
        return i <= mid?get(lson,i):cnt[ls]+get(rson,i);
    }
    ll qry(int i,bool tp)
    {return i < 1?0:query(1,1,n,i,tp);}
    void up(int i)
    {
        int x = tp?cnt[1]-get(1,1,n,i):i?get(1,1,n,i-1):0;
        int v = modify(1,1,n,i,qry(x,0));
        !tp?modify(1,1,n,i,n,b[i]*v):modify(1,1,n,1,i,b[i]*v);
    }
}t1,t2;
inline ll get(int i)
{return t1.qry(i,0)-t2.qry(i-1,0);}
ll solve(int x)
{
    t1.up(x);t2.up(x);int siz = t1.cnt[1];
    if(siz <= 1)return 0;
    ll ans = t1.qry(siz,0)-t1.qry(1,0);
    int l = 0,r = siz-1;
    while(l < r)
    {
        int mid = l+r+1>>1;
        ll s1 = get(mid),s2 = mid+1==siz?1e18:get(mid+1);
        if(s1 >= max(0ll,s2))l = mid;
        else r = mid-1;
    }
    if(l < siz-1&&get(l+1) > 0)l++;
    ans -= t1.qry(l,1)-t2.qry(l-1,1);
    l = 1;r = siz;
    while(l < r)
    {
        int mid = l+r>>1;
        ll s1 = get(mid),s2 = mid-1==0?1e18:get(mid-1);
        if(s1 > max(0ll,s2))r = mid;
        else l = mid+1;
    }
    ans -= t1.qry(siz-1,1)-t1.qry(l-1,1)-(t2.qry(siz-2,1)-t2.qry(l-2,1));
    return ans;
}
char buf[1<<21],*p1,*p2;
inline ll rd()
{
    char c;int f = 1;
    while(!isdigit(c = getchar()))if(c=='-')f = -1;
    ll x = c-'0';
    while(isdigit(c = getchar()))x = x*10+(c^48);
    return x*f;
}
int main()
{
    freopen("kte.in","r",stdin);
    freopen("kte.out","w",stdout);
    n = rd();t1.tp = 0;t2.tp = 1;
    for(int i = 1;i <= n;i++)a[i] = b[i] = rd();
    sort(b+1,b+n+1);
    for(int i = 1;i <= n;i++)
        printf("%lld\n",solve(lower_bound(b+1,b+n+1,a[i])-b));
    return 0;
}